package com.pda.gongpin.presenter;

import com.pda.gongpin.bean.ScanQueryBean;
import com.pda.gongpin.contract.ScanQueryContract;
import com.pda.gongpin.net.NetUtils;
import com.wangshen.base.net.bean.BaseAppEntity;
import com.wangshen.base.ui.mvp.base.presenter.BasePresenter;

import io.reactivex.functions.Consumer;

public class ScanQueryPresenter extends BasePresenter<ScanQueryContract .View> implements ScanQueryContract.Presenter {
    @Override
    public void getStockInfoByCode(String code) {
        NetUtils.geApi().getStockInfoByCode(code)
                .compose(this.handleEverythingResult())
                .subscribe(new Consumer<BaseAppEntity<ScanQueryBean>>() {
                    @Override
                    public void accept(BaseAppEntity<ScanQueryBean> scanQueryBeanBaseAppEntity) throws Exception {
                        getView().setData(scanQueryBeanBaseAppEntity.getData());
                    }
                }, new Consumer<Throwable>() {
                    @Override
                    public void accept(Throwable throwable) throws Exception {
                        getView().showMessage(throwable.getMessage());
                    }
                });
    }
}
